
import './App.css';
import React, { useEffect } from 'react';
import {
  BrowserRouter,
  Route,
  Switch
} from 'react-router-dom'

import { Redirect } from 'react-router-dom/cjs/react-router-dom.min';
import FingerprintJS from '@fingerprintjs/fingerprintjs'
import DeviceID from './utils/deviceId';
import LaunchMode1 from './pages/Launch/LaunchMode1';

function App() {

  useEffect(() => {

    if (!DeviceID.isValidVistorId()) {
      const fpPromise = FingerprintJS.load()

      fpPromise
        .then(fp => fp.get())
        .then(result => {
          DeviceID.saveVisitorId(result.visitorId)
        })
    }

  }, [])

  // console.log("=========base path: " + process.env.REACT_APP_BASE_PATH)

  return (
    // <BrowserRouter baseName={process.env.REACT_APP_BASE_PATH}>
    <BrowserRouter basename="/h5oceanplus">
      <div className="AppRoot">
        <div className="App">

          <Switch>
            <Route path='/launch' ><LaunchMode1 /></Route>
            <Redirect to='/launch'></Redirect>

          </Switch>
        </div>
      </div>
    </BrowserRouter>
  );
}

export default App;
